package com.huadi.firematerialident.controller;

import com.huadi.firematerialident.po.Identifier;
import com.huadi.firematerialident.po.Reviewer;
import com.huadi.firematerialident.service.IdentifierServiceImpl;
import com.huadi.firematerialident.service.ReviewerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/ident")
public class IdentifierController {

    @Autowired
    IdentifierServiceImpl identifierService;


    @RequestMapping("/identInfo")
    public String ReviewerInfo(Model model){
        List<Map<String,Object>> list = identifierService.selectIdentifierByID(identifierService.getIdentID());
        model.addAttribute("list",list);
        return "/ident/list";
    }

    @GetMapping("/identUpdate")
    public String updateReviewer(Identifier identifier, Model model){
        if(identifierService.updateIdentifier(identifier)==0){
            model.addAttribute("msg","修改失败");
            return "/ident/list";
        }
        else{
            List<Map<String,Object>> list = identifierService.selectIdentifierByID(identifierService.getIdentID());
            model.addAttribute("msg","修改成功");
            model.addAttribute("info",list);
            return "/ident/list";
        }
    }

}
